fn main() {
    let mut sequence = 0..3;
    println!("{:?}", sequence.next());
    println!("{:?}", sequence.next());
    println!("{:?}", sequence.next());
    println!("{:?}", sequence.next());

    for i in 0..3 {
        println!("{}", i);
    }

    for i in fibonacci().take(4) {
        println!("> {}", i);
    }

    for i in fibonacci().skip(4).take(4) {
        println!("> {}", i)
    }

    let array = [1u32, 3, 3, 7];
    for x in array.iter() {
        println!("> {}", x);
    }
}

struct Fib {
    cur: u32,
    next: u32,
}

impl Iterator for Fib {
    type Item = u32;

    fn next(&mut self) -> Option<Self::Item> {
        let new_next = self.cur + self.next;

        self.cur = self.next;
        self.next = new_next;
        Some(self.cur)
    }
}

fn fibonacci() -> Fib {
    Fib { cur: 1, next: 1 }
}
